from django.db import models
from db_cc.base_model import BaseModel
# Create your models here.
'''订单'''
# 订单商品表
class OrderCargo(BaseModel):

    order_id= models.IntegerField(verbose_name = '订单id')
    amount = models.IntegerField(verbose_name = '数量')
    price  = models.IntegerField(verbose_name = '单价')
    sku_id= models.ForeignKey('goods.GoodsSku', on_delete=models.CASCADE,verbose_name = '商品sku_id')
    discuss = models.CharField(max_length=255, blank=True, null=True,verbose_name = '评论')

    class Meta:
        db_table = 'order_cargo_goods'
        verbose_name = '订单商品表'
        verbose_name_plural = verbose_name

#订单信息表
class OrderMessage(BaseModel):
    PAY_NETHODS = {
        '1': '货到付款',
        '2': '微信支付',
        '3': '支付宝',
        '4': '银联支付'
    }
    PAY_NETHODS.keys()
    DRDER_STATUS = {
        1: '待支付',
        2: '待发货',
        3: '待收费',
        4: '待评价',
        5: '已完成',
    }
    PAY_METHOD_CHOICES = (
        (1, '货到付款'),
        (2, '微信支付'),
        (3, '支付宝'),
        (4, '银联支付')
    )


    ORDER_STATUS_CHOICES = (
        (1, '待支付'),
        (2, '待发货'),
        (3, '待收货'),
        (4, '待评价'),
        (5, '已完成')
    )

    order_id = models.CharField(max_length=128,primary_key=True,verbose_name='订单id')
    total_money= models.CharField(max_length=255,verbose_name = '总金额')
    order_status = models.SmallIntegerField(choices=ORDER_STATUS_CHOICES, default=1, verbose_name='订单状态')
    pay_method = models.SmallIntegerField(choices=PAY_METHOD_CHOICES, default=3, verbose_name='支付方式')
    user_id = models.ForeignKey('user.User', on_delete=models.CASCADE,verbose_name = '用户id')
    address_id = models.ForeignKey('user.Address', on_delete=models.CASCADE,verbose_name = '地址id')
    freighht  = models.DecimalField(max_digits=10, decimal_places=0,verbose_name = '运费')
    total_number= models.IntegerField(blank=True, null=True,verbose_name = '总件数')
    trade_no = models.CharField(max_length=128, verbose_name='支付编号', default='')

    class Meta:
        db_table = 'order_message_info'
        verbose_name = '订单信息表'
        verbose_name_plural = verbose_name
